package com.hqq.helloworld;

import com.google.inject.Provider;
import com.hqq.demo.MyApplet;

import javax.inject.Inject;

/**
 * Package: com.hqq
 * User: 何芊芊
 * Email: heqianqian1@jd.com
 * Date: 2018/1/21
 * Time: 13:38
 * Description:以指定方式输出字符串
 */
public class StringWritingApplet implements MyApplet {

    private Destination destination;
    private Provider<String> stringProvider;

    @Inject
    public StringWritingApplet(Destination destination, @Output Provider<String> stringProvider) {
        this.destination = destination;
        this.stringProvider = stringProvider;
    }

    private void printHelloWorld(String outputString) {
        destination.write(outputString);
    }

    @Override
    public void run() {
        printHelloWorld(stringProvider.get());
    }
}
